<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>其他辖区单位党组织基本信息</title>
<link href="/djzx/css/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="/djzx/js/jquery-1.8.1.min.js"></script>
<script language="javascript" src="/djzx/js/backPage/clientSideApp.js"></script>
<script language="JavaScript" type="text/javascript" src="/djzx/js/backPage/win_center.js"></script>
<script type="text/javascript" src="/djzx/js/layer/layer.js" ></script>
<SCRIPT language=JavaScript type=text/JavaScript>
//查询模式：0代表查询，1代表高级查询
var queryMode = 0;

var name_layer = "";
var address_layer = "";
var area_layer = "";
var type_layer = "";
var workerNum_layer = "";
var hasParty_layer = "";
var partyName_layer = "";
var isRegional_layer = "";
var memberNum_layer = "";
var leaderName_layer = "";
var leaderPolitical_layer = "";
var leaderTel_layer = "";
var note_layer = "";

window.onload = function(){
	var flag = $('#flag').val();
	if(flag != ""){
		alert(flag);
	}
	$('#flag').val('');
};

function delParty(timeKey){
	var r = confirm("确定要删除吗?");
	if(r){
		$.post(
				"/djzx/OtherPartyAction!delPartyInfo.action",
				{
					"otherParty.timeKey":timeKey
				},
				function(data){
					alert(data.message);
					if(data.success){
						location.href="/djzx/OtherPartyAction!getPartyInfoListForPage.action";
					}
				},
				"json"
				)
	}
}

function toAddParty(){
	window.location.href="/djzx/backPage/other/addPartyInfo.jsp";
}

function toEditParty(timeKey){
	window.location.href="/djzx/OtherPartyAction!toEditPartyInfo.action?otherParty.timeKey=" + timeKey + "&editFrom=1";
}

function searchParty(){
	queryMode = 0;
	ajaxParty(1);
}

function firstPage(){
	ajaxParty(1);
}

function prevPage(){
	var start =parseInt($("#start").html());
	if(start <= 1){
		start = 1;
	}else{
		start--;
	}
	ajaxParty(start);
}

function nextPage(){
	var start =parseInt($("#start").html());
	var count = parseInt($("#pageCount").html());
	if(start >= count){
		start = count;
	}else{
		start++;
	}
	ajaxParty(start);
}

function endPage(){
	var last = parseInt($("#pageCount").html());
	ajaxParty(last);
}

function ajaxParty(start){
	var name = "";
	var address = "";
	var area = "";
	var type = "";
	var workerNum = "";
	var hasParty = "";
	var partyName = "";
	var isRegional = "";
	var memberNum = "";
	var leaderName = "";
	var leaderPolitical = "";
	var leaderTel = "";
	var note = "";
	
	if(queryMode == 0){ // 查询
		var param = $.trim($('#param').val());
		var paramValue = $.trim($('#paramValue').val());
		
		if(param == 'name'){
			name = paramValue;
		}else if(param == 'address'){
			address = paramValue;
		}else if(param == 'area'){
			area = paramValue;
		}else if(param == 'type'){
			type = paramValue;
		}else if(param == 'workerNum'){
			if(isNaN(paramValue) || paramValue == ''){
				alert("请输入数字！");
				return false;
			}
			workerNum = parseInt(paramValue);
		}else if(param == 'hasParty'){
			if(paramValue == '是'){
				hasParty = 1;
			}else if(paramValue == '否'){
				hasParty = 0;
			}else{
				alert("请填“是”或者“否”");
				return false;
			}
		}else if(param == 'partyName'){
			partyName = paramValue;
		}else if(param == 'isRegional'){
			if(paramValue == '是'){
				isRegional = 1;
			}else if(paramValue == '否'){
				isRegional = 0;
			}else{
				alert("请填“是”或者“否”");
				return false;
			}
		}else if(param == 'memberNum'){
			if(isNaN(paramValue) || paramValue == ''){
				alert("请输入数字！");
				return false;
			}
			memberNum = parseInt(paramValue);
		}else if(param == 'leaderName'){
			leaderName = paramValue;
		}else if(param == 'leaderPolitical'){
			leaderPolitical = paramValue;
		}else if(param == 'leaderTel'){
			leaderTel = paramValue;
		}else if(param == 'note'){
			note = paramValue;
		}
	}else if(queryMode == 1){ // 高级查询
		name = name_layer;
		address = address_layer;
		area = area_layer;
		type = type_layer;
		workerNum = workerNum_layer;
		hasParty = hasParty_layer;
		partyName = partyName_layer;
		isRegional = isRegional_layer;
		memberNum = memberNum_layer;
		leaderName = leaderName_layer;
		leaderPolitical = leaderPolitical_layer;
		leaderTel = leaderTel_layer;
		note = note_layer;
	} 
	
	$.ajax({
		url:'${pageContext.request.contextPath}/OtherPartyAction!searchPartyList.action',
		data:{
			"page.currPage":start,
			"otherParty.name":name,
			"otherParty.address":address,
			"otherParty.area":area,
			"otherParty.type":type,
			"otherParty.workerNum":workerNum,
			"otherParty.hasParty":hasParty,
			"otherParty.partyName":partyName,
			"otherParty.isRegional":isRegional,
			"otherParty.memberNum":memberNum,
			"otherParty.leaderName":leaderName,
			"otherParty.leaderPolitical":leaderPolitical,
			"otherParty.leaderTel":leaderTel,
			"otherParty.note":note
		},
		type:'post',
		dataType:'json',
		success:function(data){
			var str="";
			if(data.map.length>0){
				$.each(data.map,function(i){
					str+='<tr><td class="td_01">'+data.map[i].index+
					'</td><td class="td_01"><a href="/djzx/OtherPartyAction!toShowPartyInfo.action?otherParty.timeKey='+data.map[i].timeKey+'" target="_blank">'+data.map[i].name+'</a>'+
					'</td><td class="td_01">'+data.map[i].address+
					'</td><td class="td_01">'+data.map[i].area+
					'</td><td class="td_01">'+data.map[i].type+
					'</td><td class="td_01">'+data.map[i].workerNum+
					'</td><td class="td_01">'+data.map[i].hasParty+
					'</td><td class="td_01">'+data.map[i].partyName+
					'</td><td class="td_01">'+data.map[i].isRegional+
					'</td><td class="td_01">'+data.map[i].memberNum+
					'</td><td class="td_01">'+data.map[i].leaderName+
					'</td><td class="td_01">'+data.map[i].leaderPolitical+
					'</td><td class="td_01">'+data.map[i].leaderTel+
					'</td><td class="td_01">'+data.map[i].note+
					'</td><td nowrap class="td_01"><a href="/djzx/OtherPartyAction!toShowPartyInfo.action?otherParty.timeKey='+data.map[i].timeKey+'" target="_blank">查看</a>|<a href="javascript:void(0)" onclick="toEditParty('+data.map[i].timeKey+')">编辑</a>|<a href="javascript:void(0)" onclick="delParty('+data.map[i].timeKey+')">删除</a></td></tr>';
				});
			}
			$("#nodeContent").html(str);
			$("#start").html(data.object.currPage);
			$("#pageCount").html(data.object.pageCount);
			$("#count").html(data.object.count);
		}
	}); 
}

function advancedQueryParty(){
	queryMode = 1;
	name_layer = $.trim($('#name').val());
	address_layer = $.trim($('#address').val());
	area_layer = $.trim($('#area').val());
	type_layer = $.trim($('#type').val());
	workerNum_layer = $.trim($('#workerNum').val());
	hasParty_layer = $.trim($('#hasParty').val());
	partyName_layer = $.trim($('#partyName').val());
	isRegional_layer = $.trim($('#isRegional').val());
	memberNum_layer = $.trim($('#memberNum').val());
	leaderName_layer = $.trim($('#leaderName').val());
	leaderPolitical_layer = $.trim($('#leaderPolitical').val());
	leaderTel_layer = $.trim($('#leaderTel').val());
	note_layer = $.trim($('#note').val());
	ajaxParty(1);
}

</SCRIPT>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<input id="flag" value="${flag }" type="hidden"/>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="25" align="center" valign="bottom" class="td06"><table width="98%" border="0" cellspacing="3" cellpadding="0">
      <tr>
        <td width="15"><img src="/djzx/images/index_32.gif" width="9" height="9"></td>
        <td valign="bottom" class="title">基本信息查询</td>
      </tr>
    </table></td>
  </tr>
</table>
<br>
<table width="95%"  border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td class="td_page">
	   查询参数：
      <select name="param" id="param">
      	<option value="name">单位名称</option>
        <option value="address">地址</option>
        <option value="area">所属片区</option>
        <option value="type">单位性质</option>
        <option value="workerNum">单位员工数</option>
        <option value="hasParty">是否建有党组织</option>
        <option value="partyName">党组织名称</option>
        <option value="isRegional">是否为区域化党建单位</option>
        <option value="memberNum">党员数</option>
        <option value="leaderName">负责人姓名</option>
        <option value="leaderPolitical">负责人政治面貌</option>
        <option value="leaderTel">负责人电话</option>
        <option value="note">备注</option>
      </select>
             参数值：
      <input name="paramValue" id="paramValue" type="text" class="input" size="10">
      <input type="button" class="buttonface02" value=" 查询 " onclick="searchParty()">
      <input type="button" class="buttonface02" value=" 高级查询 " id="advancedQuery">
	  <input type="button" class="buttonface02" value=" 新增 " onclick="toAddParty()">
    </td>
  </tr>
</table>
<br>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td nowrap class="td_top">序号</td>
    <td nowrap class="td_top">单位名称</td>
    <td nowrap class="td_top">地址</td>
    <td nowrap class="td_top">所属片区</td>
    <td nowrap class="td_top">单位性质</td>
    <td nowrap class="td_top">单位员工数</td>
    <td nowrap class="td_top">是否建有党组织</td>
    <td nowrap class="td_top">党组织名称</td>
    <td nowrap class="td_top">是否为区域化党建单位</td>
    <td nowrap class="td_top">党员数</td>
    <td nowrap class="td_top">负责人姓名</td>
     <td nowrap class="td_top">负责人政治面貌</td>
	 <td nowrap class="td_top">负责人电话</td>
	 <td nowrap class="td_top">备注</td>
	 <td nowrap class="td_top">操作</td>
  </tr>
  <tbody id="nodeContent">
  <s:iterator value="otherPartyList" var="o" status="statu">
  <tr> 
    <td class="td_01">${statu.index+1 }</td>
    <td class="td_01">
    	<a href="/djzx/OtherPartyAction!toShowPartyInfo.action?otherParty.timeKey=${o.timeKey}" target="_blank">${o.name }</a>
    </td>
    <td class="td_01">${o.address }</td>
    <td class="td_01">${o.area }</td>
    <td class="td_01">${o.type }</td>
    <td class="td_01">${o.workerNum }</td>
    <s:if test="#o.hasParty==1">
    <td class="td_01">是</td>
    </s:if>
    <s:elseif test="#o.hasParty==0">
    <td class="td_01">否</td>
    </s:elseif>
    <s:else>
    <td class="td_01"></td>
    </s:else>
    <td class="td_01">${o.partyName }</td>
    <s:if test="#o.isRegional==1">
    <td class="td_01">是</td>
    </s:if>
    <s:elseif test="#o.isRegional==0">
    <td class="td_01">否</td>
    </s:elseif>
    <s:else>
    <td class="td_01"></td>
    </s:else>
    <td class="td_01">${o.memberNum }</td>
    <td class="td_01">${o.leaderName }</td>
    <td class="td_01">${o.leaderPolitical }</td>
	<td class="td_01">${o.leaderTel }</td>
    <td class="td_01">${o.note }</td>
	<td nowrap class="td_01">
		<a href="/djzx/OtherPartyAction!toShowPartyInfo.action?otherParty.timeKey=${o.timeKey}" target="_blank">查看</a>|
		<a href="#" onclick="toEditParty(${o.timeKey})">编辑</a>|
		<a href="#" onclick="delParty(${o.timeKey })">删除</a>
	</td>
  </tr>
  </s:iterator>
  </tbody>
</table>
<table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr> 
    <td nowrap width="95%" class="td_top"></td>
  </tr>
</table>
<table width="95%"  border="0" cellpadding="0" cellspacing="0" class="table02" align="center">
  <tr>
    <td height="30" align="right">
	    <img src="/djzx/images/1.gif" width="4" height="5" align="absmiddle"> <a href="javascipt:;" onclick="firstPage()">首页</a>　
	    <img src="/djzx/images/2.gif" width="3" height="5" align="absmiddle"> <a href="javascipt:;" onclick="prevPage()">上一页</a>　 
	    <img src="/djzx/images/2-2.gif" width="3" height="5" align="absmiddle"> <a href="javascipt:;" onclick="nextPage()">下一页</a>　 
	    <img src="/djzx/images/3.gif" width="4" height="5" align="absmiddle"> <a href="javascipt:;" onclick="endPage()">末页</a>　　
	         当前第<span id="start">${page.currPage}</span>页,共<span id="pageCount">${page.pageCount}</span>页,共<span id="count">${page.count}</span>条记录
    </td>
  </tr>
</table>
<script type="text/javascript">
function hasPartyCheck(){
	var hasParty = $.trim($('#hasParty').val());
	if(hasParty == ''){
		return;
	}
	if(hasParty == 1){
		$('#partyName').fadeIn();
		$('#isRegional').fadeIn();
		//$('#partyCheck').fadeIn();
	}else if(hasParty == 0){
		$('#partyName').fadeOut();
		$('#isRegional').fadeOut();
		//$('#partyCheck').fadeOut();
	}
}

$(document).ready(function(){
	var layerW = '800px';
	var layerH = '400px';
	   
	// 高级查询界面
	$('#advancedQuery').on('click', function(){ 
		var content = '<br><table align="center" width="95%" border="0" cellspacing="0" cellpadding="0">'
				+ '<tr><td width="120" height="24" class="td_form01">单位名称</td>' 
				+ '<td nowrap class=td_form02><input type="text" size="30" id="name" /></td>'
				+ '<td width="120" class="td_form01">地址</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="address" /></td></tr>'
        		+ '<tr><td height="24" class="td_form01">所属片区</td>'
        		+ '<td nowrap class=td_form02><input type="text" size="30" id="area" /></td>'
        		+ '<td class="td_form01">单位性质</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="type" /></td></tr>'
        		+ '<tr><td height="24" class="td_form01">单位员工数</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="workerNum" /></td>'
      			+ '<td class="td_form01">是否建有党组织</td>'
      			+ '<td nowrap class=td_form02><select name="hasParty" id="hasParty" onchange="hasPartyCheck()"><option value="0">否</option><option value="1">是</option></select></td></tr>'
      			+ '<tr><td class="td_form01">党组织名称</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="partyName" /></td>'      			
      			+ '<td class="td_form01">是否为区域化党建单位</td>'
      			+ '<td nowrap class=td_form02><select name="isRegional" id="isRegional"><option value="0">否</option><option value="1">是</option></select></td>'
      			+ '<tr><td class="td_form01">党员数</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="memberNum" /></td></tr>'
      			+ '<td class="td_form01">负责人姓名</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="leaderName" /></td></tr>'
      			+ '<tr><td class="td_form01">负责人电话</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="leaderTel" /></td></tr>'
      			+ '<td class="td_form01">负责人政治面貌</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="leaderPolitical" /></td></tr>'
      			+ '<tr><td class="td_form01">备注</td>'
      			+ '<td nowrap class=td_form02><input type="text" size="30" id="note" /></td></tr></table>'
      			+ '<br><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">'
      			+ '<tr><td align="center"><input name="Submit2" type="submit" class="buttonface" value="  查询  " onClick="advancedQueryParty()"></td></tr></table>';
      			
		// 页面一打开就执行，放入ready是为了layer所需配件（css、扩展模块）加载完毕
		layer.ready(function(){ 
			//官网欢迎页
			layer.open({
				type: 1,
				//skin: 'layui-layer-lan',
				title: '高级查询',
				fix: false,
				shadeClose: true,
				maxmin: true,
				area: [layerW, layerH],
				content: content,
				success: function(layero, index){
				    console.log(layero, index);
				    hasPartyCheck();
				}
			});
		});
	});
});
</script>
</body>
</html>
